package com.ryenlii.datatrans.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

public interface ITdengineService<T> {

    int saveToDb(T var1);

    List<T> selectBySql(String var1);

    List<T> select(String var1);

    List<T> select(Map<String, Object> queryMap);

    Long selectCountFromTdBySql(String sql);

    Page<T> queryHistoryData(Integer pageSize, Integer currentPage, Map<String, Object> queryMap, Map<String, String> map);

    StringBuffer queryHistoryDataTableSql(Map<String, Object> historyDataTableMap, Boolean countFlag);

    /**
     * 获取开关状态
     *
     * @return
     */
    boolean getSwitchF();

    default String timeToString(Long time) {
        StringBuilder str = new StringBuilder();
        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
        str.append("'");
        str.append(ftf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())));
        str.append("'");
        return str.toString();
    }

}
